package com.dognessnetwork.customer.domain;

import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import cn.hutool.json.JSONObject;

@Component
@ConfigurationProperties(prefix = "person")
public class Person {

    private Map<String, String> maps;

    public Map<String, String> getMaps() {
        return maps;
    }

    public void setMaps(Map<String, String> maps) {
        this.maps = maps;
    }

    public JSONObject CheckLogin(String name, String pawd,Environment	evn) {
        // 数据库中是否包含该用户名
        JSONObject res = new JSONObject();
        if (maps.containsKey(name)) {

            String key = name;

            // 检验密码是否正确
            if (maps.get(key).equals(pawd)) {
                res.put("result", 200);
                res.put("username", name);
                return res;
            } else {
                res.put("result", 500);
                //res.put("info", "<p style=\"color: #FFB800;\" th:text=\"${wrongpassword}\"></p>");
                return res;
            }
        }else{
        	res.put("result", 100);
        	res.put("username", name);
        	return	res;
        }
        //res.put("result", 400);
        //res.put("info","<p style=\"color: #FFB800;\" th:text=\"${notexist}\"></p>");
        //return res;
    }
}
